package com.ruoyi.partybuilding.controller;

import io.swagger.annotations.*;
import org.springframework.data.domain.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import lombok.var;
import com.ruoyi.common.core.domain.*;
import com.ruoyi.common.core.page.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.partybuilding.domain.Treedic;
//import com.ruoyi.partybuilding.service.TreedicService;
import com.ruoyi.partybuilding.common.*;

/**treedic
 * 树形字典;(pb_treedic)表控制层
 * @author : He-LiangLiang@Outlook.com
 * @date : 2024-12-10
 */
@Api(tags = "树形字典")
@RestController
@RequestMapping("/partybuilding/Treedic")
public class TreedicController extends EQueryController<Treedic>{

    @ApiOperation("详情")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:query')")
    @GetMapping(value = "/{id}")
    public R<Treedic> getInfo(@PathVariable("id") Long id)
    {
        return super.getInfo(id);
    }
    @ApiOperation("查询,type=pb_cities省市信息")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:list')")
    @GetMapping("query")
    public R<Page<Treedic>> query(Treedic whereObj, PageDomain pageRequest) {
        return super.queryPage(whereObj, pageRequest);
    }


    @ApiOperation("列表,对query的rouyi兼容包装")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:list')")
    @GetMapping("list")
    public TableDataInfo list(Treedic entity, PageDomain pageRequest) {
        var page= super.queryPage(entity, pageRequest);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(page.getData().getContent());
        rspData.setTotal(page.getData().getTotalElements());
        return rspData;
    }
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:add')")
    @Log(title = "树形字典", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public R<Long> add(@RequestBody Treedic entity){
        return super.add(entity);
    }
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:remove')")
    @Log(title = "树形字典", businessType = BusinessType.DELETE)
    @PostMapping("remove/{ids}")
    public R<Long> remove(@PathVariable("ids") Long[] ids){
        return super.remove(Arrays.stream(ids).toArray());
    }
    @ApiOperation("编辑")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:edit')")
    @Log(title = "树形字典", businessType = BusinessType.UPDATE)
    @PostMapping("edit")
    public  R<Long> edit(@RequestBody Treedic entity){
        return super.edit(entity);
    }
    @ApiOperation("导出")
    @PreAuthorize("@ss.hasPermi('partybuilding:Treedic:export')")
    @Log(title = "树形字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(Treedic entity, PageDomain pageRequest,HttpServletResponse response)
    {
        super.export(entity,pageRequest,null,response);
    }
}